//
//  AllTopicTableViewCell.m
//  FlyGift
//
//  Created by lanou3g on 15/7/15.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "AllTopicTableViewCell.h"

@implementation AllTopicTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.coverImageView = [[UIImageView alloc]initWithFrame:CGRectMake(kP6width(5), kP6Height(4), kScreenWidth - kP6width(10), (kScreenWidth - kP6width(10)) / 2.18)];
        self.coverImageView.backgroundColor = [UIColor lightGrayColor];
        self.coverImageView.layer.cornerRadius = 8.0f;
        self.coverImageView.layer.masksToBounds = YES;
        self.coverImageView.userInteractionEnabled = YES;
        [self.contentView addSubview:_coverImageView];
        
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.coverImageView.frame.size.height / 2 - kP6Height(40), self.coverImageView.frame.size.width, kP6Height(40))];
        self.titleLabel.text = @"主标题";
        self.titleLabel.textColor = [UIColor whiteColor];
        self.titleLabel.font = [UIFont systemFontOfSize:20];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self.coverImageView addSubview:_titleLabel];
        
        
        CGPoint center = self.coverImageView.center;
        UIImageView *centerImageView = [[UIImageView alloc]initWithFrame:CGRectMake(center.x - kP6width(10), center.y - kP6Height(10), kP6width(20), kP6Height(20))];
        centerImageView.image = [UIImage imageNamed:@"face_icon_flower_on@2x"];
        
        UIView *leftLine = [[UIView alloc]initWithFrame:CGRectMake(center.x - kP6width(160), center.y - kP6Height(0.5), kP6width(150), kP6Height(1))];
        leftLine.backgroundColor = [UIColor whiteColor];
        
        UIView *rightLine = [[UIView alloc]initWithFrame:CGRectMake(center.x + kP6width(10), center.y - kP6Height(0.5), kP6width(150), kP6Height(1))];
        rightLine.backgroundColor = [UIColor whiteColor];

        [self.coverImageView addSubview:centerImageView];
        [self.coverImageView addSubview:leftLine];
        [self.coverImageView addSubview:rightLine];

        
        self.subtitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.titleLabel.frame.size.height + self.titleLabel.frame.origin.y + kP6Height(10), self.coverImageView.frame.size.width, kP6Height(30))];
        self.subtitleLabel.text = @"副标题";
        self.subtitleLabel.textColor = [UIColor whiteColor];
        self.subtitleLabel.font = [UIFont systemFontOfSize:18];
        self.subtitleLabel.textAlignment = NSTextAlignmentCenter;
        [self.coverImageView addSubview:_subtitleLabel];
        
        
    }
    return self;
}

- (void)setAllTopicModel:(AllTopicModel *)allTopicModel
{
    if (_allTopicModel != allTopicModel)
    {
        _allTopicModel = allTopicModel;
    }
    
    self.titleLabel.text = self.allTopicModel.title;
    
    self.subtitleLabel.text = self.allTopicModel.subtitle;
    
    [self.coverImageView setImageWithURL:[NSURL URLWithString:self.allTopicModel.cover_image_url] placeholderImage:[UIImage imageNamed:@"285*176-1"]];
}

@end
